[feat] Add triggers domain and event catalog#4738
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
⚠️ Not ready to approve
The new triggers router currently turns “unknown provider” cases into HTTP 500s and several new Pydantic models use mutable defaults that diverge from established repo conventions.
Pull request overview
This PR introduces a new Triggers domain (read-only event catalog backed by Composio) and refactors tool connection persistence into a shared Connections domain backed by the renamed gateway_connections table, wiring both into the FastAPI entrypoints and adding OSS/EE acceptance coverage.
Changes:
- Add
/triggers/catalog/*endpoints, DTOs, registry/service layers, and a Composio triggers adapter. - Extract tool connection auth + persistence into a standalone
core/connectionsdomain and Postgres DAO/DBE (gateway_connections), including an Alembic rename migration. - Add OSS + EE acceptance tests for triggers catalog and
/tools/connectionscontract, and update wiring/permissions.
File summaries
| File | Description |
|---|---|
| api/oss/tests/pytest/unit/models/test_lifecycle_conventions.py | Updates lifecycle convention module list to reference connections DBEs. |
| api/oss/tests/pytest/acceptance/triggers/test_triggers_catalog.py | Adds OSS acceptance tests for triggers catalog endpoints. |
| api/oss/tests/pytest/acceptance/triggers/init.py | Package init for OSS triggers acceptance tests. |
| api/oss/tests/pytest/acceptance/tools/test_tools_connections.py | Adds OSS acceptance tests pinning /tools/connections behavior. |
| api/oss/src/dbs/postgres/triggers/init.py | Introduces triggers DB package placeholder. |
| api/oss/src/dbs/postgres/connections/mappings.py | Maps Connections DTOs to/from the new Connection DBE. |
| api/oss/src/dbs/postgres/connections/dbes.py | Adds ConnectionDBE mapped to gateway_connections. |
| api/oss/src/dbs/postgres/connections/dao.py | Adds ConnectionsDAO for CRUD/query operations on gateway_connections. |
| api/oss/src/dbs/postgres/connections/init.py | Package init for Postgres connections module. |
| api/oss/src/core/triggers/service.py | Adds triggers orchestration for provider/event catalog operations. |
| api/oss/src/core/triggers/registry.py | Adds adapter registry for triggers providers. |
| api/oss/src/core/triggers/providers/composio/catalog.py | Implements Composio triggers catalog HTTP calls + parsing. |
| api/oss/src/core/triggers/providers/composio/adapter.py | Adds Composio triggers adapter (catalog + subscription verbs). |
| api/oss/src/core/triggers/providers/composio/init.py | Lazy import wrapper for Composio triggers adapter. |
| api/oss/src/core/triggers/providers/init.py | Package init for triggers providers. |
| api/oss/src/core/triggers/interfaces.py | Defines triggers gateway interface contract. |
| api/oss/src/core/triggers/exceptions.py | Adds triggers domain exceptions. |
| api/oss/src/core/triggers/dtos.py | Adds triggers domain DTOs for providers/events. |
| api/oss/src/core/triggers/init.py | Package init for triggers domain. |
| api/oss/src/core/tools/service.py | Refactors tools service to delegate connection ops to ConnectionsService. |
| api/oss/src/core/tools/providers/composio/adapter.py | Removes connection-auth verbs from tools adapter (now in connections adapter). |
| api/oss/src/core/tools/interfaces.py | Removes DAO/connection-auth methods from tools gateway interface. |
| api/oss/src/core/tools/dtos.py | Removes tool-connection DTOs now owned by connections domain. |
| api/oss/src/core/connections/utils.py | Renames module docstring; continues to host oauth state helpers. |
| api/oss/src/core/connections/service.py | Adds ConnectionsService owning gateway connections lifecycle. |
| api/oss/src/core/connections/registry.py | Adds adapter registry for connection providers. |
| api/oss/src/core/connections/providers/composio/adapter.py | Introduces Composio connection-auth adapter (initiate/status/refresh/revoke). |
| api/oss/src/core/connections/providers/composio/init.py | Lazy import wrapper for Composio connections adapter. |
| api/oss/src/core/connections/providers/init.py | Package init for connections providers. |
| api/oss/src/core/connections/interfaces.py | Defines DAO + gateway interfaces for connections domain. |
| api/oss/src/core/connections/exceptions.py | Adds connections domain exceptions. |
| api/oss/src/core/connections/dtos.py | Adds connections domain DTOs (Connection/Usage + adapter request/response). |
| api/oss/src/core/connections/init.py | Package init for connections domain. |
| api/oss/src/apis/fastapi/triggers/router.py | Adds FastAPI router exposing triggers catalog endpoints (+ caching/EE auth). |
| api/oss/src/apis/fastapi/triggers/models.py | Adds FastAPI response envelope models for triggers catalog. |
| api/oss/src/apis/fastapi/triggers/init.py | Package init for FastAPI triggers API. |
| api/oss/src/apis/fastapi/tools/router.py | Switches oauth state decoding import to connections domain utils. |
| api/oss/src/apis/fastapi/tools/models.py | Switches tool connection envelopes to use connections domain DTOs. |
| api/oss/databases/postgres/migrations/core_oss/versions/oss000000002_rename_tool_connections_to_gateway_connections.py | Alembic rename migration for tool_connections → gateway_connections (+ constraint/index renames). |
| api/entrypoints/routers.py | Wires up connections + triggers services/routers and closes adapters on shutdown. |
| api/ee/tests/pytest/acceptance/triggers/test_triggers_catalog.py | Adds EE acceptance tests for triggers catalog. |
| api/ee/tests/pytest/acceptance/triggers/init.py | Package init for EE triggers acceptance tests. |
| api/ee/tests/pytest/acceptance/tools/test_tools_connections.py | Adds EE acceptance tests for /tools/connections behavior. |
| api/ee/tests/pytest/acceptance/tools/init.py | Package init for EE tools acceptance tests. |
| api/ee/src/core/access/permissions/types.py | Adds triggers permissions and includes VIEW_TRIGGERS in default permissions. |
Copilot's findings
Comments suppressed due to low confidence (1)
api/oss/src/apis/fastapi/triggers/models.py:37
eventsuses a mutable default ([]). UseField(default_factory=list)to avoid shared mutable state across model instances and to match the project’s established Pydantic conventions.
class TriggerCatalogEventsResponse(BaseModel):
count: int = 0
total: int = 0
cursor: Optional[str] = None
events: List[TriggerCatalogEvent] = []
- Files reviewed: 14/20 changed files
- Comments generated: 7
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from oss.src.core.triggers.exceptions import AdapterError | ||
| from oss.src.core.triggers.service import TriggersService |
| def decorator(func): | ||
| @wraps(func) | ||
| async def wrapper(*args, **kwargs): | ||
| try: | ||
| return await func(*args, **kwargs) | ||
| except AdapterError as e: | ||
| cause = e.__cause__ | ||
| if not ( | ||
| isinstance(cause, httpx.HTTPStatusError) | ||
| and cause.response is not None | ||
| and cause.response.status_code == status.HTTP_401_UNAUTHORIZED | ||
| ): | ||
| raise | ||
|
|
||
| raise HTTPException( | ||
| status_code=status.HTTP_424_FAILED_DEPENDENCY, | ||
| detail=e.message, | ||
| ) from e | ||
|
|
||
| return wrapper |
| from enum import Enum | ||
| from typing import Any, Dict, List, Optional | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
| # | ||
| categories: List[str] = [] | ||
| logo: Optional[str] = None |
| from typing import List, Optional | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
||
| from oss.src.core.triggers.dtos import ( |
| class TriggerCatalogProvidersResponse(BaseModel): | ||
| count: int = 0 | ||
| providers: List[TriggerCatalogProvider] = [] | ||
|
|
| Under EE the catalog is gated on the VIEW_TOOLS permission (the triggers domain | ||
| shares the gateway permission surface with tools); a developer role carries | ||
| VIEW_TOOLS, so this verifies the endpoint behaves once the gate is satisfied. |
… adapter Stand up the inbound triggers domain mirroring tools (action -> event): the read-only events catalog and ComposioTriggersAdapter behind TriggersGatewayInterface (list/get events, create/set-status/delete subscription on ti_* instances). - New core/triggers, apis/fastapi/triggers, dbs/postgres/triggers (skeleton). - Verified Composio v3 REST paths (triggers_types, trigger_instances/...). - Dedicated VIEW_TRIGGERS permission (own triad, viewer default); not VIEW_TOOLS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aabbf52 to
87e5041
Compare
Context
Triggers are the inbound dual of webhooks: Composio provider events that invoke Agenta workflows, the way Agenta events already POST to user endpoints. This lane adds the triggers domain skeleton and the first working slice, the event catalog, so the UI and later lanes have a real domain and a real catalog API to build against.
Changes
Adds the
triggersdomain modeled on the shipped tools domain:core/triggers/—TriggersService, the provider-keyed adapter portTriggersGatewayInterface, exceptions, and the Composio adapter plus its catalog reader.apis/fastapi/triggers/— the catalog routes: list/fetch providers, and list/fetch events for a provider integration. Responses are cached for five minutes; the catalog is global, not per-project.VIEW_TRIGGERS/EDIT_TRIGGERS/RUN_TRIGGERS, registered in the role defaults (viewer gets VIEW, annotator gets RUN, editor gets EDIT), mirroring the tools triad. Triggers are gated on their own permission, not onVIEW_TOOLS.The catalog routes reuse the connections domain from the base lane: a trigger catalog is read against a connected integration.
Tests / notes
COMPOSIO_API_KEY, matching the shipped tools and connections suites.dbs/postgres/triggers/is an empty package here; the subscription and delivery tables arrive in the WP3 lane.